package nothing.dao.hibernate;

import nothing.model.MeasurementRatio;
import nothing.dao.MeasurementRatioDao;
import org.appfuse.dao.hibernate.GenericDaoHibernate;

import java.util.List;

public class MeasurementRatioDaoHibernate extends GenericDaoHibernate<MeasurementRatio, Long> implements MeasurementRatioDao {

    public MeasurementRatioDaoHibernate() {
        super(MeasurementRatio.class);
    }

    @SuppressWarnings("unchecked")
    public List<MeasurementRatio> findByMeasurementName(String name, String otherName) {
        Object[] values = {name, otherName, name, otherName};        
        return getHibernateTemplate().
                find("from MeasurementRatio mr " +
                "where (mr.manyMeasurement.name = ? and mr.oneMeasurement.name = ?) "
                +"or   (mr.oneMeasurement.name = ?  and mr.manyMeasurement.name = ?)", values);
    }


}
